package com.wymobilearchitecture.heade_frist.state.state;

import com.wymobilearchitecture.heade_frist.state.CandyMachine;

/**
 * 投币,有硬币状态
 * 执行有硬币的逻辑
 */
public class HasQuarterStateItem implements State{

    private CandyMachine candyMachine;
    public HasQuarterStateItem(CandyMachine candyMachine){
        this.candyMachine = candyMachine;
    }

    @Override
    public void insertQuarter() {
        System.out.println("已有硬币不需要重复投递");
    }

    @Override
    public void ejectQuarter() {
        System.out.println("执行退币");
        candyMachine.setState(candyMachine.noQuarterStateItem);
        System.out.println("退回已硬币");
    }


    @Override
    public void dispense() {
        System.out.println("执行糖果");
        candyMachine.setState(candyMachine.noQuarterStateItem);
        System.out.println("糖果已发放");
    }
}
